/**
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved. 
 */
package test.procedure;

import java.lang.reflect.InvocationTargetException;
import java.sql.Array;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.wilmar.process.entity.query.HistoryProcessInstanceQueryObject;
import com.wilmar.process.enumerate.EnumDatabaseDataType;
import com.wilmar.process.procedure.HistoryProcessInstanceProcedure;

/**
 * @author MaKuBEX Email:makubexnet@gmail.com
 * @version 1.0.0 May 17, 2010
 * @since 1.0.0
 * 
 */
public class HistoryProcessInstanceProcedureTestCase extends BaseTester {
	public void testSqlGenerate() {
		Connection conn = super.getConnection();
		HistoryProcessInstanceQueryObject obj = new HistoryProcessInstanceQueryObject();
		obj.setProcessDefinitionId("process_main-2");
		HashMap map = new HashMap();
		map
				.put(
						HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONID,
						EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map
				.put(
						HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONKEY,
						EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map
				.put(
						HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONINAME,
						EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_INSTANCEID,
				EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_INSTANCEKEY,
				EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_TASK_INSTANCEID,
				EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_STATE,
				EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_OUTSYSTEM,
				EnumDatabaseDataType.ARRAY_VARCHAR.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_MAX_START_TIME,
				EnumDatabaseDataType.DATE.getType());
		map.put(HistoryProcessInstanceQueryObject.PROPERTY_MIN_START_TIME,
				EnumDatabaseDataType.DATE.getType());
		Map pms = null;
		try {
			pms = obj.format(map, conn);
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}

		HistoryProcessInstanceProcedure
				.getListHistoryProcessInstance(
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONID),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONKEY),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_DEFINITIONINAME),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_INSTANCEKEY),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_PROCESS_INSTANCEID),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_STATE),
						(Array) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_OUTSYSTEM),
						(Date) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_MIN_START_TIME),
						(Date) pms
								.get(HistoryProcessInstanceQueryObject.PROPERTY_MAX_START_TIME),
						0, 5, new ResultSet[1], conn);
		try {
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
